from utils.decorator import singleton


@singleton
class Admin(object):

    def __init__(self) -> None:
        self.sid = None

    def is_admin(self, sid) -> None:
        # 判断当前的用户是否时控制者
        if self.sid == sid:
            return True
        else:
            return False

    def get_admint(self):
        return self.sid

    def set_admin(self, sid):
        cache_id = self.sid
        self.sid = sid
        return cache_id

    def release_admin(self, sid) -> None:
        if self.is_admin(sid):
            self.sid = None
            return 'success'
        else:
            return 'fail'
